package model.time;

import java.util.logging.Level;

import org.tiling.scheduling.Scheduler;
import org.tiling.scheduling.SchedulerTask;
import org.tiling.scheduling.examples.iterators.DailyIterator;

import platform.PlatformObjectFactory;
import util.LoggingUtils;

public class TimerTask {

    private final Scheduler scheduler = new Scheduler();
    private final int hourOfDay, minute, second;

    public TimerTask(int hourOfDay, int minute, int second) {
        this.hourOfDay = hourOfDay;
        this.minute = minute;
        this.second = second;
    }

    public void start() {
        scheduler.schedule(new SchedulerTask() {
            public void run() {
            	//restartPlayer();
            	System.out.println("Every five second");
            }
            
        }, new DailyIterator(hourOfDay, minute, second));
    }
    
    private void restartPlayer()
    {
		LoggingUtils.log(Level.SEVERE, "RestartTimerTask.java in .run method() scheduled by player at "+hourOfDay+":"+minute+":"+second+" AM");
		PlatformObjectFactory.getInstance().getCommandExecutor().restartPlayer();
   }
    
   public static void main(String[] args) {
    	TimerTask alarmClock = new TimerTask(14, 36, 5);
       alarmClock.start();
    }
}
